#include "Model/DailyCalendarRule.hpp"
#include <boost/test/auto_unit_test.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <boost/date_time/posix_time/time_formatters.hpp>
#include <boost/date_time/posix_time/posix_time_io.hpp>

namespace
{

using namespace Model;

BOOST_AUTO_TEST_CASE( testShortTimeConversion)
{
	DailyCalendarRule::ShortTime time( 102030);
	unsigned int hh = DailyCalendarRule::calculateHours( time),
		mm = DailyCalendarRule::calculateMinutes( time),
		ss = DailyCalendarRule::calculateSeconds( time);
	BOOST_CHECK_EQUAL( 10, hh);
	BOOST_CHECK_EQUAL( 20, mm);
	BOOST_CHECK_EQUAL( 30, ss);
}

// ---------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE( testCalculateTime)
{
	DailyCalendarRule::ShortTime time( 102030);
	Calendar::Date date( 2008, 10, 12);
	Calendar::Time expectedTime( date, boost::posix_time::hours( 10) + boost::posix_time::minutes( 20) + boost::posix_time::seconds( 30));
	Calendar::Time resultedTime = DailyCalendarRule::calculateTime( date, time);
	BOOST_CHECK_EQUAL( expectedTime, resultedTime);
}


} // namespace
